package com.ruoyi.qualityManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.qualityManagement.domain.InboundInspection;
import com.ruoyi.qualityManagement.service.IInboundInspectionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 入库检管理Controller
 * 
 * @author admin
 * @date 2024-07-05
 */
@RestController
@RequestMapping("/qualityManagement/inboundInspection")
public class InboundInspectionController extends BaseController
{
    @Autowired
    private IInboundInspectionService inboundInspectionService;

    /**
     * 查询入库检管理列表
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:inboundInspection:list')")
    @GetMapping("/list")
    public TableDataInfo list(InboundInspection inboundInspection)
    {
        startPage();
        List<InboundInspection> list = inboundInspectionService.selectInboundInspectionList(inboundInspection);
        return getDataTable(list);
    }

    /**
     * 导出入库检管理列表
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:inboundInspection:export')")
    @Log(title = "入库检管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InboundInspection inboundInspection)
    {
        List<InboundInspection> list = inboundInspectionService.selectInboundInspectionList(inboundInspection);
        ExcelUtil<InboundInspection> util = new ExcelUtil<InboundInspection>(InboundInspection.class);
        util.exportExcel(response, list, "入库检管理数据");
    }

    /**
     * 获取入库检管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:inboundInspection:query')")
    @GetMapping(value = "/{inspectionId}")
    public AjaxResult getInfo(@PathVariable("inspectionId") Long inspectionId)
    {
        return success(inboundInspectionService.selectInboundInspectionByInspectionId(inspectionId));
    }

    /**
     * 新增入库检管理
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:inboundInspection:add')")
    @Log(title = "入库检管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InboundInspection inboundInspection)
    {
        return toAjax(inboundInspectionService.insertInboundInspection(inboundInspection));
    }

    /**
     * 修改入库检管理
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:inboundInspection:edit')")
    @Log(title = "入库检管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InboundInspection inboundInspection)
    {
        return toAjax(inboundInspectionService.updateInboundInspection(inboundInspection));
    }

    /**
     * 删除入库检管理
     */
    @PreAuthorize("@ss.hasPermi('qualityManagement:inboundInspection:remove')")
    @Log(title = "入库检管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inspectionIds}")
    public AjaxResult remove(@PathVariable Long[] inspectionIds)
    {
        return toAjax(inboundInspectionService.deleteInboundInspectionByInspectionIds(inspectionIds));
    }
}
